class Receta < ActiveRecord::Base
  has_many :ingredientes 
  has_many :pasos
  
  accepts_nested_attributes_for :ingredientes, :pasos, :allow_destroy => true, :reject_if => proc { |attrs| attrs.all? { |k,v| v.blank? }  }
  
  validates_presence_of :titulo
  validates_length_of :ingredientes, :minimum => 1, :message => 'Se necesita al menos un ingrediente'
  validates_length_of :pasos, :minimum => 1, :message => 'Se necesita al menos un paso'
end
